Skip to content

api: refuse a contract call whose method the executor cannot find - #132

Merged
EnzinoBB merged 4 commits into
masterfrom
feat/sc-call-precheck
Oct 30, 2026
Merged

EnzinoBB merged 4 commits into
masterfrom
feat/sc-call-precheck

Conversation

@EnzinoBB

Copy link
Copy Markdown
Collaborator

Summary

The executor picks the method of a call with commons-beanutils' getMatchingAccessibleMethod (same name, same argument count, each argument's class from its Variant assignable to the declared type). A call that matches no method fails on every node and the caller pays the fee anyway. Typical cases: a v1 token's transfer(String, BigDecimal) called with the amount as v_string, a v0 token's transfer(String, String) called with a v_big_decimal, a misspelt method.

TransactionFlow now checks method and arguments against the contract's methods (getContractMethods, asked once per contract, cached) and refuses such a call before it reaches the network, naming the expected signature and the Variant to use, e.g. transfer(java.lang.String, java.math.BigDecimal): argument 2 is java.math.BigDecimal (v_big_decimal), the call passes v_string. The idea is the same as eth_estimateGas refusing a call that would revert.

Conservative: only certain mismatches are refused. Arguments and declared types outside String, BigDecimal, boolean, int, long, double (+ wrappers) and byte[] count as possible matches, overloads are considered, Object's methods pass, and without an answer from the executor nothing is checked. API only: nothing that reaches the network changes.

CI:

  • ci/testnet/tokens.py: both wrong-type transfers must be refused by the API with the sender's inner id unchanged (nothing sent);
  • testnet.yml: inputs tokens and tokens_via (token checks with strict API checks);
  • ci/contracts/executor_harness.py: compares the executors' answers only, not the scenarios' expectations nor the API-only token standard, so that the executor's CI can run it against 1518 (EnzinoBB/contract-executor).

Test plan

  • nodetests --gtest_filter=CallCheck*: matching calls, wrong amount types (v1 and v0), unknown method, wrong count, Object's methods, uncertain types, overloads
  • Private network, CONTRACTS=1 TOKENS=1 TOKENS_VIA=5 TOKENS_STRICT_API=1 with the restart of n5: 0 failures, 0 findings; both wrong-type transfers refused, inner id unchanged; every consensus and token API check passes
  • Harness, release executor 1518 against the current executor master (build 1549): 0 differing answers
  • CI

🤖 Generated with Claude Code

The executor picks the method of a call with commons-beanutils' getMatchingAccessibleMethod:
same name, same number of arguments, each argument's class (from its Variant) assignable to
the declared type. A call that matches no method fails on every node, and the caller pays
the fee all the same: a v1 token's transfer(String, BigDecimal) called with the amount as a
v_string, a v0 token's transfer(String, String) with a v_big_decimal, a misspelt method.

TransactionFlow now checks the method and its arguments against the contract's methods
(getContractMethods, asked once per contract) before the call reaches the network, and
refuses it with the expected signature and the Variant to use. Only certain mismatches are
refused: arguments and declared types outside String, BigDecimal, boolean, int, long, double
(and their wrappers) and byte[] are taken as possible matches, as are Object's methods; with
no answer from the executor nothing is checked. API only: what reaches the network does not
change.

CI: tokens.py checks that both wrong-type transfers are refused and that the sender's inner
id did not move; testnet.yml gets the tokens and tokens_via inputs (strict token API checks);
the executor harness compares only the answers (not the scenarios' expectations, nor the
token standard, which only the API reads), so that a fixed executor passes against 1518.
@EnzinoBB
EnzinoBB merged commit 3faeb1e into master Oct 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant